package com.ruoyi.project.menzhen.controller;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.menzhen.domain.Doctor;
import com.ruoyi.project.menzhen.domain.User;
import com.ruoyi.project.menzhen.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value="/menzhen/doctor",method= RequestMethod.GET)
public class DoctorController extends BaseController {
    @Autowired
    private DoctorService doctorService;
    @PreAuthorize("@ss.hasPermi('system:Doctor:query')")
    @GetMapping(value = "/{pdId}")
    public AjaxResult getInfo(@PathVariable Long pdId)
    {
        return AjaxResult.success(doctorService.selectDoctorByIdService(pdId));
    }
    @PreAuthorize("@ss.hasPermi('menzhen:doctor:list')")
    @GetMapping("/list")
    public TableDataInfo list(Doctor doctor)
    {
        startPage();
        List<Doctor> list = doctorService.DoctorService(doctor);
        return getDataTable(list);
    }
    @PreAuthorize("@ss.hasPermi('menzhen:doctor:edit')")
    @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Doctor doctor)
    {
        return toAjax(doctorService.UpdateDoctor(doctor));
    }
}
